import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ytbusiness/config/style.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/page/auto_makers/shop_home/order_details/order_info.dart';
import 'package:ytbusiness/page/auto_makers/shop_home/order_widget/enquiry_item.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/widgets.dart';

//已退款
class Refunded extends StatefulWidget {
  @override
  _RefundedState createState() => _RefundedState();
}

class _RefundedState extends State<Refunded> {
  List<String> typeList = ["原厂原包", "品牌", "拆车", "OEM"];
  bool isShow = false;//显示隐藏未退款商品
  int checkIndex = 0;//初始选中

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () {
        //输入框失焦
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: Scaffold(
        backgroundColor: YTStyle.bgColor,
        appBar: customAppBar(context, title: "已退款"),
        body: CustomScrollView(
          slivers: [
            //订单信息
            SliverToBoxAdapter(
              child: OrderInfo(),
            ),

            //联系方式
            SliverToBoxAdapter(
              child: Container(
                padding:
                EdgeInsets.only(bottom: setWidth(10), top: setWidth(10)),
                color: Colors.white,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    link(image: "blue_kefu.png",title: "在线联系",phone: "10086"),
                    link(image: "blue_phone_link.png",title: "电话联系",phone: "10086"),
                  ],
                ),
              ),
            ),

            //询价信息
            SliverToBoxAdapter(
              child: Container(
                margin: EdgeInsets.only(top: setWidth(15)),
                padding: EdgeInsets.only(
                    top: setWidth(18),
                    left: setWidth(15),
                    bottom: setWidth(13)),
                decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border(
                        bottom: BorderSide(
                            color: Color(0xffF0F0F0), width: setWidth(0.5)))),
                child: Text(
                  "询价信息",
                  style: TextStyle(
                      color: Color(0xff323232),
                      fontSize: setSp(15),
                      fontWeight: FontWeight.w600),
                ),
              ),
            ),

            //退款列表
            SliverList(
                delegate: SliverChildBuilderDelegate(
                      (context, index) {
                    return EnquiryItem(
                      typeTitle: "已退款",
                      checkIndex: checkIndex,
                      onCheckUpdate: (value){
                        print(value);
                      },
                    );
                  },
                  childCount: isShow?(typeList.length >0 ? typeList.length:1):1,
                )),


            //隐藏显示
            SliverToBoxAdapter(
              child: GestureDetector(
                behavior: HitTestBehavior.opaque,
                onTap: (){
                  setState(() {
                    isShow = !isShow;
                  });
                },
                child: Container(
                  alignment: Alignment.center,
                  margin: EdgeInsets.only(bottom: setWidth(12)),
                  padding: EdgeInsets.only(
                      top: setWidth(12),
                      bottom: setWidth(12)),
                  color: Colors.white,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Container(
                        child: Text(
                          isShow?"隐藏未退款的${typeList.length-1}个商品":"已隐藏未退款的${typeList.length-1}个商品",
                          style: TextStyle(
                              color: Color(0xff989898),
                              fontSize: setSp(14)),
                        ),
                      ),

                      Container(
                        margin: EdgeInsets.only(left: setWidth(6),right: setWidth(6)),
                        child: Text(
                          isShow?"收起": "展开",
                          style: TextStyle(
                              color: Color(0xff989898),
                              fontSize: setSp(14),
                              fontWeight: FontWeight.w600),
                        ),
                      ),
                      SizedBox(width: setWidth(12),
                        height: setWidth(6),
                        child: Image.asset(isShow?"assets/images/shouqi.png":"assets/images/zhankai.png",width: setWidth(12),
                          height: setWidth(6),fit: BoxFit.cover,),
                      ),

                    ],
                  ),
                ),
              ),
            ),


            //结算信息
            SliverToBoxAdapter(
              child: settlementInfo(price:"1259.00",serve: "3280.00",sum: "1259.00"),
            ),

            SliverToBoxAdapter(
              child:SizedBox(
                height: setWidth(20),
              ),
            ),
            SliverToBoxAdapter(
              child: Container(
                padding: EdgeInsets.only(top: setWidth(18),bottom: setWidth(18),left: setWidth(15),right: setWidth(15)),
                color: Colors.white,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      margin: EdgeInsets.only(bottom: setWidth(22)),
                      child: Text(
                        "退款信息",
                        style: TextStyle(
                            color: Color(0xff323232),
                            fontSize: setSp(16),
                            fontWeight: FontWeight.w600),
                      ),
                    ),

                    //退款时间
                    Container(
                      margin: EdgeInsets.only(bottom: setWidth(18)),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            width: setWidth(64),
                            child: Text("退款时间:",style: TextStyle(color: Color(0xff323232),fontSize: setSp(14)),),
                          ),
                          Expanded(
                            child: Container(
                              child: Text("2020-11-27 11:21",style: TextStyle(color: Color(0xff323232),fontSize: setSp(14))),
                            ),
                          ),
                        ],
                      ),
                    ),
                    //退款金额
                    Container(
                      margin: EdgeInsets.only(bottom: setWidth(18)),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            width: setWidth(64),
                            child: Text("退款金额:",style: TextStyle(color: Color(0xff323232),fontSize: setSp(14)),),
                          ),
                          Expanded(
                            child: Container(
                              child: Text("￥5895.00元/1件",style: TextStyle(color: Color(0xff323232),fontSize: setSp(14))),
                            ),
                          ),
                        ],
                      ),
                    ),

                  ],
                ),
              ),

            ),

            SliverToBoxAdapter(
              child:SizedBox(
                height: setWidth(40),
              ),
            )
          ],
        ),
      ),
    );
  }

}
